import { requestClient } from '#/api/request';

// 创建
export async function createSysOrgApi(data: any) {
  return requestClient.post('/system/create-sys-org', data);
}

// 修改
export async function updateSysOrgApi(data: any) {
  return requestClient.patch('/system/update-sys-org', data);
}

// 更新状态
export async function updateStatusApi(data: any) {
  return requestClient.patch('/system/update-status', data);
}

//查询
export async function getSysOrgTreeApi(params: any) {
  return requestClient.get('/system/get-sys-org-tree', { params });
}

// 获取租户id
export async function getSystemTenantApi(params?: any) {
  return requestClient.get('/system/get-system-tenant', { params });
}

// 获取基础信息
export async function getBaseInfoApi() {
  let domain;
  const hostname = window.location.hostname
  if (hostname.includes('localhost') || /^\d{1,3}(\.\d{1,3}){3}$/.test(hostname)) {
    // domain = import.meta.env.VITE_DEV;
    // domain = import.meta.env.VITE_DEV_ADMIN;
    domain = 'localhost';
  } else {
    domain = window.location.host;
  }

  return requestClient.post('/system/get-base-info', {domain});
}



/**
 * 获取滑块验证码图片
 * @returns Promise<any>
 */
export async function getSliderCaptchaApi() {
  return requestClient.get('/system/open/captcha/generate');
}

/**
 * 校验滑块验证码
 * @param params 包含验证码id和滑块X坐标
 * @returns Promise<any>
 */
export async function verifySliderCaptchaApi(params: { id: string; sliderX: number }) {
  return requestClient.get('/system/open/captcha/verify', { params });
}
